﻿@using LotteryVoteMVC.Models
@using LotteryVoteMVC.Resources
@using LotteryVoteMVC.Utility
@using LotteryVoteMVC.Core
@model PagedList<BetSheet>
@{
    ViewBag.Title = Resource.BetList;
    Layout = "~/Views/Shared/Main.cshtml";
}
@section Header
{
    <script src="@Url.Content("~/Scripts/Customer/TableBase.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/TableBase.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/BetSheet.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Pager/pagerGray.css")" rel="stylesheet" type="text/css" />
}
@{
    int index = 0;
    decimal turnover = 0, comm = 0, netAmount = 0;
}
<table cellpadding="0" cellspacing="0">
    <thead>
        <tr>
            <td>
                @Resource.No
            </td>
            <td>
                @Resource.SheetNum
            </td>
            <td>
                @Resource.UserName
            </td>
            <td>
                @Resource.Time
            </td>
            <td>
                @Resource.Num
            </td>
            <td>
                @Resource.Company
            </td>
            <td style="width: 35%">
                @Resource.Amount
            </td>
            <td>
                @Resource.Turnover
            </td>
            <td>
                @Resource.Commission
            </td>
            <td>
                @Resource.NetAmount
            </td>
            <td>
                @Resource.Function
            </td>
        </tr>
    </thead>
    <tbody>
        @foreach (var sheet in Model)
        { 
            <tr @(sheet.Status == BetStatus.Invalid ? "class=canceld" : "")>
                <td>
                    @(++index)
                </td>
                <td>
                    @sheet.SheetId
                </td>
                <td>
                    @ViewBag.CurrentUser.UserName
                </td>
                <td>
                    @sheet.CreateTime
                </td>
                <td>
                    <strong style="color: #771919">
                        @Extended.ParseSheetNum(sheet.Num)
                    </strong>
                </td>
                <td>
                    @sheet.BetCompany
                </td>
                <td>
                    @sheet.WagerList.ParseWagersToTable()
                </td>
                <td>
                    @sheet.Turnover.ToString("N")
                </td>
                <td>
                    @sheet.Commission.ToString("N")
                </td>
                <td>
                    @sheet.NetAmount.ToString("N")
                </td>
                <td>
                    @Html.ActionLink(Resource.Detail, "Index", "Order", new { Id = sheet.SheetId }, null)
                    @if (sheet.CanCancel())
                    {
                        @Html.ActionLink(Resource.Cancel, "Cancel", new { Id = sheet.SheetId })
                    }
                </td>
            </tr>
                    turnover += sheet.Turnover;
                    comm += sheet.Commission;
                    netAmount += sheet.NetAmount;
        }
    </tbody>
    <tfoot>
        <tr>
            @for (int t = 0; t < 6; t++)
            {
                <td>
                </td>
            }
            <td style="text-align: right">@Resource.Total
            </td>
            <td>@turnover.ToString("N")
            </td>
            <td>@comm.ToString("N")
            </td>
            <td>@netAmount.ToString("N")
            </td>
            <td>
            </td>
        </tr>
    </tfoot>
</table>
@Html.Pager(Model)
